package org.kia.manager;

import android.content.Context;
import android.preference.PreferenceManager;

/**
 * 
 * @author Amir Lazarovich
 */
public class SettingsManager {
	
	//////////////////////////////////////////////
	// Constants
	//////////////////////////////////////////////
	private static final String SERVER_ADDRESS = "server_address";
	private static final String SERVER_ADDRESS_DEFAULT = "http://ladaatmerosh.appspot.com/";
    
	private static final String MOCKING = "mocking";
	private static final boolean MOCKING_DEFAULT = false; // TODO SettingsManager: don't forget this mocking flag on
	
	//////////////////////////////////////////////
	// Members
	//////////////////////////////////////////////
	private static SettingsManager sInstance;
	
	//////////////////////////////////////////////
	// Constructors & Singleton related methods
	//////////////////////////////////////////////
	
	/**
	 * Private constructor to prohibit more instances of this class
	 */
	private SettingsManager() {
		
	}
	
	/**
	 * Get the (only) instance of this class
	 * 
	 * @return
	 */
	public synchronized static SettingsManager getInstance() {
		if (sInstance == null) {
			sInstance = new SettingsManager();
		}
		
		return sInstance;
	}

	//////////////////////////////////////////////
	// Public
	//////////////////////////////////////////////
	
	 /**
     * Get the server's address
     *
     * @param context
     * @return
     */
    public String getServerAddress(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context).getString(SERVER_ADDRESS, SERVER_ADDRESS_DEFAULT);
    }
    
    /**
     * Is mocking all data from the server?
     * 
     * @param context
     * @return
     */
    public boolean isMocking(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(MOCKING, MOCKING_DEFAULT);
    }
    
    // TODO SettingsManager:: need to implement setters
}
